var picture = angular.module('picture', []);

function studyRouteConfig($routeProvider) {
    $routeProvider.
       when('/list', {
        controller: ListController,
        templateUrl: '/js/export/list.html'
    }).when('/view/id/:id', {
        controller: ViewController,
        templateUrl: '/js/export/view.html'
    }).otherwise({
        redirectTo: '/list'
    })
}
picture.config(studyRouteConfig);

picture.directive('picLoading', function(){
    return {
        template: '<img src="/images/loading.gif" id="loading">'
    };
});
function ListController($scope, $http) {
    $http.get('/export/list').success(function(result) {
        $scope.items = result;
        jQuery('#loading').hide();
    });
}

function ViewController($scope, $routeParams, $http) {
    if ($routeParams.id) {
        $http.get('/export/view/id/' + $routeParams.id).success(function(data, status, headers, config) {
            $scope.item = data;
            jQuery('#loading').hide();
        });
    }
}